package day07;

import java.util.Scanner;

public class CalTotalAvg {
    public static void main(String[] args) {
        //1.录入成绩
        int[] scores = enterdata();
        //3计算平均分
        int a = sum(scores);
        //4输出总分和平均分
        System.out.println("平均分是"+a);
    }
    //录入成绩
    public static int[] enterdata() {
        Scanner scanner = new Scanner(System.in);
        int[] array = new int[6];
        for (int i = 0;i<array.length;i++){
            System.out.println("请输入第"+(i+1)+"个评委的分数");
            array[i] = scanner.nextInt();
        }
        return array;
    }
    //计算总分
    public static int maxmin(int[] score){
        int x = 0;
        int max = score[0];
        int min = score[0];
        for (int j : score) {
            if (j > max) {
                max = j;
            }
            if (j < min) {
                min = j;
            }
            x += j;
        }
        return x-max-min;
    }
    //计算平均分
    public static int sum(int[] sums){
        int su = maxmin(sums);
        return su/(sums.length-2);
    }
}
